
package net.tutwiz.sessionBeans;

import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import net.tutwiz.model.User;
import net.tutwiz.persistence.UserPersistenceManager;


/**
 *
 * @author danielwirdehall
 */
@ManagedBean
@SessionScoped
public class SessionBean implements Serializable {

	public User user = null;
	public String tmpUserName;
	public String tmpUserPassword;

	public String getTmpUserName() {
		return tmpUserName;
	}

	public void setTmpUserName(String tmpUserName) {
		this.tmpUserName = tmpUserName;
	}

	public String getTmpUserPassword() {
		return tmpUserPassword;
	}

	public void setTmpUserPassword(String tmpUserPassword) {
		this.tmpUserPassword = tmpUserPassword;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	
	
	public void login(){
		UserPersistenceManager em = new UserPersistenceManager();
		user = em.get(tmpUserName);
		if (!user.getPassword().equals(tmpUserPassword)) {
			user = null;
		}
	}
	
}
